package com.chenyu.controller;


import com.chenyu.service.IVerifyCodeService;
import com.chenyu.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 晴
 * @version 1.0
 * @description:
 * @date 2024/6/18 11:38
 */
@RestController
@RequestMapping("/verifycode")
@Api(tags = "验证接口")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    /**
    * @Description: 生成图形验证码 返回base64的图片流
    * @Param: [key]
    * @Return: com.chenyu.base.utils.AjaxResult
    * @Author: 晴
    * @Data: 2024/6/18
    */
    @GetMapping("/imageCode/{key}")
    @ApiOperation("图片验证码")
    public AjaxResult getImgCode(@PathVariable String key){
        return verifyCodeService.getImgCode(key);
    }

    /**
    * @Description: 获取短信验证码
    * @Param: [params]
    * @Return: com.chenyu.base.utils.AjaxResult
    * @Author: 晴
    * @Data: 2024/6/18
    */
    @PostMapping("/sendSmsCode")
    @ApiOperation("获取短信验证码")
    public AjaxResult sendSms(@RequestBody Map<String,String> params){
        return verifyCodeService.sendSms(params);
    }


    /**
    * @Description: 微信登录绑定手机号时获取验证码
    * @Param: [params]
    * @Return: com.chenyu.base.utils.AjaxResult
    * @Author: 晴
    * @Data: 2024/6/20
    */
    @PostMapping("/smsbind")
    @ApiOperation("微信登录绑定手机号时获取验证码")
    public AjaxResult bindSms(@RequestBody Map<String ,String> params){
        return verifyCodeService.bindSms(params);
    }
}
